BUGFIX: template-no-invalid-role — support DPUB/Graphics-ARIA and role-fallback lists#2729
Draft
johanrd wants to merge 6 commits intoember-cli:masterfrom
Draft
BUGFIX: template-no-invalid-role — support DPUB/Graphics-ARIA and role-fallback lists#2729johanrd wants to merge 6 commits intoember-cli:masterfrom
johanrd wants to merge 6 commits intoember-cli:masterfrom
Conversation
…pport DPUB-/Graphics-ARIA and role-fallback lists
Two related fixes, shared rewrite.
1. Replace the hand-maintained VALID_ROLES (~90 WAI-ARIA 1.2 tokens)
with a derived list from aria-query (concrete — non-abstract — role
keys), plus a small ARIA 1.3 draft-role allowlist that aria-query
doesn't yet ship.
Effect: DPUB-ARIA roles (doc-abstract, doc-chapter, …) and
Graphics-ARIA roles (graphics-document, graphics-object,
graphics-symbol) are no longer flagged as invalid.
2. Split the role value on whitespace before validating. A role
attribute is a list of tokens per ARIA 1.2 §5.4 (role fallback).
Each token must individually be valid.
Effect: role="tabpanel row", role="doc-appendix doc-bibliography",
and role="graphics-document document" now pass; role="tabpanel
row foobar" flags the first invalid token ("foobar") instead of
rejecting the whole string as one opaque role name.
Error message now names the specific offending token. Three existing
invalid tests updated accordingly (previously expected the whole
string; now the specific token).
Ten new valid tests cover DPUB/Graphics and the fallback-list shape.
Translates 32 cases from peer-plugin rules:
- jsx-a11y aria-role
- vuejs-accessibility aria-role
- lit-a11y aria-role
Fixture documents parity after this fix:
- DPUB-ARIA and Graphics-ARIA roles accepted (via aria-query).
- Space-separated role tokens accepted when all are valid, and the
invalid-token variant names the specific offending token.
Remaining divergences (case-insensitive comparison, empty-string role
not flagged) are annotated inline.
…kens `associationlist`, `associationlistitemkey`, and `associationlistitemvalue` are not present in the current WAI-ARIA 1.3 editor's draft (https://w3c.github.io/aria/). Earlier commit listed all five as draft tokens; only `comment` and `suggestion` are actually proposed. Drop the three phantom tokens and the tests that accepted them as valid. With this change the rule now correctly flags `role='associationlist'` and siblings as invalid, matching peer behavior (jsx-a11y, vue-a11y, lit-a11y all reject them).
…Copilot review)
The PR body claimed the ARIA 1.3 draft allowlist covers 5 roles (associationlist,
associationlistitemkey, associationlistitemvalue, comment, suggestion). The
code only listed 2 ('comment', 'suggestion'); the gap was invisible because
no tests exercised any of them. Verified against aria-query 5.3.2:
roles.has() returns false for all 5, so all 5 belong in the inline allowlist
until aria-query catches up.
Also: when reporting presentation/none on a semantic element, include the
offending token in the message data instead of the raw role attribute
string — avoids surfacing e.g. 'presentation listbox' when only
'presentation' is the issue.
Tests: add 5 valid cases in each of the gts and hbs blocks covering all
ARIA 1.3 draft roles.
49fafaa to
7e45da3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two related fixes in one rewrite. Both were false positives that rejected documented-valid ARIA patterns.
1. DPUB-ARIA and Graphics-ARIA roles
doc-*(40+ roles) andgraphics-*(3 roles) tokens.aria-queryindexes them under itsrolesmap.VALID_ROLES(~90 tokens) covered only WAI-ARIA base roles.role="doc-abstract",role="graphics-document", etc., were flagged as invalid.Fix: derive
VALID_ROLESfromaria-query's concrete (non-abstract) role keys. Covers ~127 roles automatically.A small ARIA 1.3 draft allowlist (
associationlist,associationlistitemkey,associationlistitemvalue,comment,suggestion) is kept inline becausearia-querydoesn't yet ship those.2. Whitespace-separated role fallback lists
roleis a list of tokens. The UA picks the first one it recognises; the others are fallbacks.role="tabpanel row"as one opaque value —VALID_ROLES.has("tabpanel row")is false — and flagged the whole string as invalid.Fix: split on whitespace, validate each token. The error message now names the first offending token (
Invalid ARIA role 'foobar') rather than the whole string.Before/after
<div role="doc-abstract"><svg role="graphics-document"><div role="tabpanel row"><section role="doc-appendix doc-bibliography"><div role="tabpanel row foobar">'foobar')Three existing invalid tests updated to reflect the per-token error message; ten new valid tests cover the fixes.
Prior art
aria-rolearia-query'sroles.keys()directly;.split(' ')the value and checks each token against the set of concrete roles.aria-rolearia-roleisConcreteAriaRole, so multi-token fallback lists likerole="tabpanel row"fail.@angular-eslint/template'svalid-ariarule validatesaria-*attribute names and values rather thanroletokens, so it has no direct analog for the fallback-list fix.Audit fixture
Includes translated peer-plugin test fixture at
tests/audit/aria-role/peer-parity.jsdocumenting our rule's behavior relative to jsx-a11y / vuejs-accessibility / lit-a11y. Not wired into the default test run; intended for behavioral-parity auditing.